﻿/// <summary>
/// Flags操作扩展
/// </summary>
public static class ESF_FlagsOprExtend
{
    /// <summary>
    /// 是否有指定位值
    /// </summary>
    /// <param name="_self">本身值</param>
    /// <param name="_bitIndex">位索引</param>
    /// <returns>true:包含,false:不包含</returns>
    public static bool ESF_ExistsBit(this int _self, int _bitIndex)        
    {
        _bitIndex = 1 << _bitIndex;
        return (_self & _bitIndex) == _bitIndex;
    }

    /// <summary>
    /// 添加位值
    /// </summary>
    /// <param name="_self">本身值</param>
    /// <param name="_bitIndex">位索引</param>
    /// <returns>LayerMask</returns>
    public static int ESF_AddBit(this int _self, int _bitIndex)
    {
        return _self | (1 << _bitIndex);
    }

    /// <summary>
    /// 移除位值
    /// </summary>
    /// <param name="_self">本身值</param>
    /// <param name="_bitIndex">位索引</param>
    /// <returns>LayerMask</returns>
    public static int ESF_DelBit(this int _self, int _bitIndex)
    {
        return _self & ~(1 << _bitIndex);
    }
}
